﻿namespace MultipleMonitorVideo
{
    using System.Collections.Generic;
    using System.Windows;
    using Modules;
    using Utilities;
    using ViewModels;
    using Views;
    using Screen = System.Windows.Forms.Screen;

    /// <summary>
    ///     Interaction logic for App.xaml
    /// </summary>
    public partial class App
    {
        private Screen mainScreen;
        private Screen secondaryScreen;

        private void GetScreens()
        {
            this.mainScreen = ScreenManager.GetPrimaryScreen();
            this.secondaryScreen = ScreenManager.GetSecondaryScreen() ?? this.mainScreen;
        }

        private void CreateWindows()
        {
            IList<Module> modules = new List<Module>
            {
                new OverlayInfoModule(new OverlayInfoControlViewModel(), 0),
                new VideoModule(new VideoControlViewModel(), 1)
            };

            ModuleManager moduleManager = new ModuleManager(modules);
            
            ControlPanelView controlPanelView = WindowFactory.BuildWindow<ControlPanelView>(this.mainScreen);
            //controlPanelView.DataContext = new ControlPanelViewModel
            //{
            //    ModuleManager = moduleManager
            //};
            
            controlPanelView.ShowMaximized();

            // TEMP: Hardcode OverlayInfoModule as default module
            ////moduleManager.UpdateCurrentModule(typeof(VideoModule), this.secondaryScreen);
            moduleManager.UpdateCurrentModule(typeof(OverlayInfoModule), this.secondaryScreen);
        }

        private void App_OnExit(object sender, ExitEventArgs e)
        {
        }
    }
}